<?php
//项目初始化文件
if(!defined('IN_T')){
	die('hacking attempt');
}

//session设置
//session_set_cookie_params(0,'/','.krpano100.com');   //设置session作用域
session_start();

//自定义企业后台目录，目录名须与此一致
define('TONGJI_PATH','tongji');

//程序所在根目录
define('ROOT_PATH',str_replace(TONGJI_PATH.'/include/init.php','',str_replace('\\', '/', __FILE__)));

/* 配置文件 */
require_once ROOT_PATH.'config/config.php';

//smarty配置文件
require_once ROOT_PATH.'source/include/smarty/smarty.config.php';

/* 常量 */
require_once ROOT_PATH.'source/include/inc_constant.php';

/* 语言库 */
require_once ROOT_PATH.'source/language/common.php';

/* 基本类 */
require_once ROOT_PATH.'source/include/cls_json.php';
require_once ROOT_PATH.'source/include/cls_db.php';
require_once ROOT_PATH.'source/include/cls_base.php';
require_once ROOT_PATH.'source/include/cls_common.php';   //Common方法
require_once ROOT_PATH.'source/include/cls_transaction.php';   //Transaction方法
require_once ROOT_PATH.'source/include/cls_curl.php';
require_once ROOT_PATH.TONGJI_PATH.'/include/lib_main.php';

/* 初始化基本类 */
$Json = new Json;
$Db = MyPDO::getInstance($db_host,$db_user,$db_pass,$db_name,$db_charset);
$Base = new Base($db_name,$db_prefix);

/* 将登录信息输出到前台 */
$tongji = array(
 'id' => intval($_SESSION['tongji']['id']),
 'name' => isset($_SESSION['tongji']['name']) ? $_SESSION['tongji']['name']: '',
 'is_admin' => intval($_SESSION['tongji']['is_admin']),  //是否是管理员
 'priv' => $_SESSION['tongji']['priv'],
);

/* 7天内免登录 */
if($_COOKIE['tongji']['id']>0 && $tongji['id']<1){ 
   $sql = "select id,name,priv,passwd from ".$Base->table('admin_tongji')." where id=".$_COOKIE['tongji']['id']."";
   $u = $Db->query($sql,'Row');
   $u['priv'] = $Json->decode($u['priv']);
   $hashcode = Common::encrypt($u['name'].$u['passwd']);
   if($hashcode==$_COOKIE['tongji']['hashcode']){
     unset($u['passwd']);
	 $_SESSION['tongji'] = $tongji = $u;
   }
}

$tp->assign('tongji',$tongji);

/* 语言变量输出到前台 */
Transaction::get_site_config();	//提取站点配置
$_lang['tongji_path'] = TONGJI_PATH;
$tp->assign('_lang',$_lang);

//重新赋值模板目录
$tp->template_dir = ROOT_PATH.TONGJI_PATH.'/template';

?>